/*
 * 遍历txt文件
 * g++ CodingTraining/cpp/ifstreamDemo/ifstreamDemo.cpp -I. -DDEBUG -fexec-charset=GBK
 * ./a CodingTraining/cpp/ifstreamDemo/summary_report.xml
 */
#include <fstream>
#include <iostream>
#include <string>
#include "../log/log.h"

int main(int args, char** argv)
{
    if (args == 1) {
        LOG("input file path that you need.");
        return 0;
    }

    std::ifstream ifs(argv[1],std::ifstream::in);

    if (ifs.is_open()) {
        int i=0;
        std::string s;
        LOG("start to loop.");
        while(std::getline(ifs,s)) {
            LOG("%d:%s", i++, s.c_str());
        }
        ifs.close();
    }
    else {
        LOG("Open file faild. %s",argv[1]);
    }

    return 0;
}